<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta content="width=device-width, initial-scale=1, maximum-scale=1,
			shrink-to-fit=no" name="viewport">
    <title>书友网首页</title>
    <link rel="stylesheet" href="./assets/css/app.min.css">
    <link rel="stylesheet" href="./assets/css/style.css">
    <link rel="stylesheet" href="./assets/css/components.css">
    <link rel="stylesheet" href="./assets/css/custom.css">
    <link rel='shortcut icon' type='image/x-icon' href='./assets/img/favicon.ico'/>
    <!-- 引入样式 -->
    <link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
    <style>
        .el-tag + .el-tag {
            margin-left: 10px;
        }
        .button-new-tag {
            margin-left: 10px;
            height: 32px;
            line-height: 30px;
            padding-top: 0;
            padding-bottom: 0;
        }
        .input-new-tag {
            width: 90px;
            margin-left: 10px;
            vertical-align: bottom;
        }
    </style>
    <style>
        [v-cloak]{
            display: none;
        }
    </style>
</head>

<body>
<div id="indexVue" v-cloak>
    <!--<div class="loader"></div>-->
    <div id="app">

        <div class="main-wrapper main-wrapper-1">
            <div class="navbar-bg"></div>

            <user-cart :avatar="user.avatar" :account="user.account"></user-cart>
            <!-- 左侧菜单页 -->
            <div class="main-sidebar sidebar-style-2">
                <aside id="sidebar-wrapper">
                    <div class="sidebar-brand">
                        <a href="Index.html">
                            <img alt="image" src="./assets/img/logo.png" class="header-logo"/>
                            <span class="logo-name">书友网</span>
                        </a>
                    </div>
                    <div class="sidebar-user">
                        <div class="sidebar-user-picture">
                            <img alt="image" :src="user.avatar">
                        </div>
                        <div class="sidebar-user-details">
                            <div class="user-name">{{user.nickName}}</div>
                            <div class="user-role">{{user.account}}</div>
                        </div>
                    </div>
                    <el-menu background-color="#fff" text-color="#000" active-text-color="#409EFF" unique-opened
                             :collapse="isCollapse"
                             :collapse-transition="false"
                             :default-active="activePath">
                        <!-- 一级菜单 -->
                        <template  v-for="item in menuList">
                            <el-submenu v-if="item.children.length > 0" :index="item.id + ''" :key="item.id">
                                <!-- 一级菜单的模板区域 -->
                                <template slot="title">
                                    <i :class="item.icon"></i>
                                    <span>{{item.menuName}}</span>
                                </template>

                                <!-- 二级菜单 -->
                                <el-menu-item v-if="item.children" :index="subItem.path" v-for="subItem in item.children" :key="subItem.id" @click="saveNavState(subItem.path)">
                                    <template slot="title">
                                        <span>{{subItem.menuName}}</span>
                                    </template>
                                </el-menu-item>
                            </el-submenu>
                            <el-menu-item v-else  :index="item.path" :key="item.id" @click="saveNavState(item.path)">
                                <!-- 一级菜单的模板区域 -->
                                <template slot="title">
                                    <i :class="item.icon"></i>
                                    <span>{{item.menuName}}</span>
                                </template>
                            </el-menu-item>
                        </template>

                    </el-menu>
                </aside>
            </div>
            <!-- Main Content -->
            <div class="main-content">
                <section class="section">
                    <div class="row ">
                        <div class="col-xl-3 col-lg-6">
                            <div class="card l-bg-green-dark">
                                <div class="card-statistic-3">
                                    <div class="card-icon card-icon-large"><i class="fa fa-award"></i></div>
                                    <div class="card-content">
                                        <h4 class="card-title">用户总数</h4>
                                        <span>{{adminIndex.totalUserCount}}</span>
                                        <div class="progress mt-1 mb-1" data-height="8">
                                            <div class="progress-bar l-bg-purple" role="progressbar" data-width="100%" aria-valuenow="25"
                                                 aria-valuemin="0" aria-valuemax="100"></div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="col-xl-3 col-lg-6">
                            <div class="card l-bg-cyan-dark">
                                <div class="card-statistic-3">
                                    <div class="card-icon card-icon-large"><i class="fa fa-briefcase"></i></div>
                                    <div class="card-content">
                                        <h4 class="card-title">本周新增</h4>
                                        <span>{{adminIndex.weekCount}}</span>
                                        <div class="progress mt-1 mb-1" data-height="8">
                                            <div class="progress-bar l-bg-orange" role="progressbar" data-width="100%" aria-valuenow="25"
                                                 aria-valuemin="0" aria-valuemax="100"></div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="col-xl-3 col-lg-6">
                            <div class="card l-bg-purple-dark">
                                <div class="card-statistic-3">
                                    <div class="card-icon card-icon-large"><i class="fa fa-globe"></i></div>
                                    <div class="card-content">
                                        <h4 class="card-title">我的好友</h4>
                                        <span>{{adminIndex.myFriendCount}}</span>
                                        <div class="progress mt-1 mb-1" data-height="8">
                                            <div class="progress-bar l-bg-cyan" role="progressbar" data-width="25%" aria-valuenow="25"
                                                 aria-valuemin="0" aria-valuemax="100"></div>
                                        </div>

                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="col-xl-3 col-lg-6">
                            <div class="card l-bg-orange-dark">
                                <div class="card-statistic-3">
                                    <div class="card-icon card-icon-large"><i class="fa fa-money-bill-alt"></i></div>
                                    <div class="card-content">
                                        <h4 class="card-title">系统访问量</h4>
                                        <span>{{adminIndex.allCount}}</span>
                                        <div class="progress mt-1 mb-1" data-height="8">
                                            <div class="progress-bar l-bg-green" role="progressbar" data-width="25%" aria-valuenow="25"
                                                 aria-valuemin="0" aria-valuemax="100"></div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-12 col-sm-12 col-lg-6">
                            <div class="card">
                                <div class="card-header">
                                    <h4>系统当前周用户</h4>
                                </div>
                                <div class="card-body">
                                    <div id="chartNow" ></div>
                                </div>
                            </div>
                        </div>
                        <div class="col-12 col-sm-12 col-lg-6">
                            <div class="card">
                                <div class="card-header">
                                    <h4>系统最近访问量</h4>
                                </div>
                                <div class="card-body">
                                    <div class="recent-report__chart">
                                        <div id="chartNew3"></div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </section>

            </div>
            <my-footer></my-footer>
        </div>
    </div>
</div>
<el-dialog :visible.sync="dialogVisible">
    <img width="100%" :src="dialogImageUrl" alt="">
</el-dialog>

<script src="./common/js/vue.js"></script>


<script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.5.0/jquery.min.js"></script>
<script src="./compont/foot.js"></script>
<script src="./compont/UserCart.js"></script>
<script src="./common/js/common.js"></script>
<script src="https://cdn.bootcdn.net/ajax/libs/layer/2.3/layer.js"></script>
<script src="https://unpkg.com/element-ui/lib/index.js"></script>

<script src="./assets/js/app.min.js"></script>
<!-- JS Libraies -->
<script src="./assets/bundles/apexcharts/apexcharts.min.js"></script>
<!-- Page Specific JS File -->
<script src="./assets/js/page/chart-apexcharts.js"></script>
<!-- Template JS File -->
<script src="./assets/js/scripts.js"></script>
<!-- Custom JS File -->
<script src="./assets/js/custom.js"></script>
<script type="text/javascript">
    function chartNew(tableData) {
        var options = {
            chart: {
                height: 350,
                type: 'bar',
            },
            plotOptions: {
                bar: {
                    horizontal: false,
                    endingShape: 'rounded',
                    columnWidth: '55%',
                },
            },
            dataLabels: {
                enabled: false
            },
            stroke: {
                show: true,
                width: 2,
                colors: ['transparent']
            },
            series: [{
                name: '用户个数',
                data: tableData
            }],
            xaxis: {
                categories: ['周一', '周二', '周三', '周四', '周五', '周六', '周日'],
                labels: {
                    style: {
                        colors: '#9aa0ac',
                    }
                }
            },
            yaxis: {
                title: {
                    text: '当前周新增用户'
                },
                labels: {
                    style: {
                        color: '#9aa0ac',
                    }
                }
            },
            fill: {
                opacity: 1

            },
            tooltip: {
                y: {
                    formatter: function (val) {
                        return "新增" + val + " 位用户"
                    }
                }
            }
        }

        var chart = new ApexCharts(
            document.querySelector("#chartNow"),
            options
        );

        chart.render();


    }
    function chartNew3(tableData) {
        var options = {
            chart: {
                height: 350,
                type: 'line',
                shadow: {
                    enabled: true,
                    color: '#000',
                    top: 18,
                    left: 7,
                    blur: 10,
                    opacity: 1
                },
                toolbar: {
                    show: false
                }
            },
            colors: ['#77B6EA', '#545454'],
            dataLabels: {
                enabled: true,
            },
            stroke: {
                curve: 'smooth'
            },
            series: [{
                name: "High - 2013",
                data: tableData
            }],
            title: {
                text: '系统本周访问量',
                align: 'left'
            },
            grid: {
                borderColor: '#e7e7e7',
                row: {
                    colors: ['#f3f3f3', 'transparent'], // takes an array which will be repeated on columns
                    opacity: 0.5
                },
            },
            markers: {
                size: 7
            },
            xaxis: {
                categories: ['周一', '周二', '周三', '周四', '周五', '周六', '周日'],
                labels: {
                    style: {
                        colors: '#9aa0ac',
                    }
                }
            },
            yaxis: {
                title: {
                    text: '系统访问量'
                },
                labels: {
                    style: {
                        color: '#9aa0ac',
                    }
                },
                min: 0,
                max: 80
            },
            legend: {
                position: 'top',
                horizontalAlign: 'right',
                floating: true,
                offsetY: -25,
                offsetX: -5
            }
        }

        var chart = new ApexCharts(
            document.querySelector("#chartNew3"),
            options
        );

        chart.render();
    }
</script>
</body>


<script>
    var tableData =  [];
    const vm = new Vue({
        el: "#indexVue",
        data: {
            adminIndex:{},
            user :{
                avatar : '',
                nickName:'',
                userId:'',
                account:'',
            },
            // 左侧菜单数据
            menuList: [],
            // 是否折叠
            isCollapse: false,
            // 被激活的链接地址
            activePath: '',
        },
        created() {
            this.getMenuList()
            this.getUserInfoList()
            this.getAdminIndex()
            this.activePath = window.localStorage.getItem('activePath')
        },
        methods:{
            getUserInfoList(){
                var userId = localStorage.getItem("userId");
                var account = localStorage.getItem("account");
                var nickName = localStorage.getItem("nickName");
                var avatar = localStorage.getItem("avatar");
                this.user.account = account;
                this.user.userId = userId;
                this.user.nickName = nickName;
                this.user.avatar = avatar;
            },

            getAdminIndex(){
                const that = this;
                HttpGet("/index/getAdminIndex",null,function (res) {
                    if (res.result == true){
                        that.adminIndex = res.data;
                        chartNew(res.data.weekUserCountList)
                        chartNew3(res.data.visitCount);
                    }else{
                        layer.msg("获取列表失败！请刷新重试~",{icon:2,time:2000})
                    }
                })
            },
            getMenuList(){
                const that = this;
                HttpGet("/menu/getList",null,function (res) {
                    if (res.result == true){
                        that.menuList = res.data;
                    }else{
                        layer.msg("获取列表失败！请刷新重试~",{icon:2,time:2000})
                    }
                })
            },
            // 点击按钮，切换菜单的折叠与展开
            toggleCollapse() {
                this.isCollapse = !this.isCollapse
            },
            // 保存链接的激活状态
            saveNavState(activePath) {
                window.localStorage.setItem('activePath', activePath)
                this.activePath = activePath
                window.location.href = activePath;
            }
        },
    })
</script>
</body>

</html>
